<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>js函数使用</title>
    <script>
        function my_add(num1=0, num2=0) {
            var sum_num = num1+num2;
            document.getElementById('value').innerHTML=sum_num;
        }
        function my_func() {
            // var num1 = parseInt(document.getElementById('num1').innerHTML);
            var num1 = parseInt(document.getElementById('num1').value);
            var num2 = parseInt(document.getElementById('num2').value);
            if(!num1 && !num2){
                my_add();
            }
            else {
                my_add(num1,num2);
            }
        }

        function my_demo_func(value1, value2="坚果", value3="abc"){
            window.alert(value1+value2+value3);
        }

        function my_demo_func_01(a, b) {
            return a * b;
        }
    </script>
</head>

<h2>计算两个数之和</h2>
<p>
<!--    <span id="num1">11</span>-->
    <input type="number" id="num1">
    <span>+</span>
<!--    <span id="num2">15</span>-->
    <input type="number" id="num2">
    <span>=</span>
    <span id="value"></span>
</p>
<button onclick=my_func()>点击计算</button>
<script>
    // my_demo_func();
    window.alert(my_demo_func_01(10, 5));
</script>

</html>